package june.circlecontroller;

import android.app.Activity;
import android.graphics.PointF;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class CircleControllerActivity extends Activity {

	TextView tv;
	CircleController circleController;
	GameMain gameMain;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        gameMain = (GameMain)findViewById(R.id.gameMain1);
        
        tv = (TextView)findViewById(R.id.tv);
        circleController = (CircleController)findViewById(R.id.circleController1);
        circleController.setControllorHandler(handler);
        
        
        
        Button b = (Button)findViewById(R.id.button1);
        b.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				circleController.circleExtands();
			}
		});
    }
    
    Handler handler = new Handler(){
    	public void handleMessage(Message msg) {
    		
    		if(msg.what == CircleController.CIRCLE_CONTROLLER){
    			PointF point = (PointF)msg.obj;
    			tv.setText("감가산값 : " + point.x + ", " + point.y);
    			gameMain.setAvataPoint(point);
    		}
    		
    	};
    };
}